package com.example.thirdhomework

import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)

        //Activity2
        val editText = findViewById<EditText>(R.id.editTextText4)
        val button1 = findViewById<Button>(R.id.button1)

        button1.setOnClickListener {
            val intent = Intent(this, MainActivity2::class.java)
            val inputText = editText.text.toString()
            intent.putExtra("param_key", inputText)
            startActivity(intent)
        }

        //Activity3
        val intent = intent
        val data = intent.getStringExtra("param_key")
        val textView = findViewById<TextView>(R.id.textView2)
        textView.text = data

        val button2= findViewById<Button>(R.id.button2)
        button2.setOnClickListener {
            startActivity(Intent(this, MainActivity3::class.java))
        }

        //Activity4
        val button3= findViewById<Button>(R.id.button5)
        button3.setOnClickListener {
            startActivity(Intent(this, MainActivity4::class.java))
        }

        //Activity5
        val button4 = findViewById<Button>(R.id.button7)
        button4.setOnClickListener{
            startActivity(Intent(this,MainActivity5::class.java))
        }


        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
    }
}